home *** CD-ROM | disk | FTP | other *** search
/ Adobe Graphics & Publishing SDK 1996 December / Adobe Graphics & Publishing SDK 1996 December.iso / pc / pm65sdk / sourcecode / c_language / open / common / opencpy.cpp < prev    next >
C/C++ Source or Header  |  1996-09-10  |  4KB  |  147 lines

  1. /*
  2.  *--- opencpy.cpp ----------------------------------------------------------
  3.  * Copyright (c) 1992-96 Adobe Systems, Inc.  All rights reserved.
  4.  *
  5.  * PageMaker plug-in OpenCopy.
  6.  *-----------------------------------------------------------------------
  7.  */
  8.  
  9. /* ---------------- PageMaker SDK include files ---------------- */
  10. #include "PMPlugin.h"
  11. #include "CIInterfaceManager.h"
  12. #include "PMEvent.h"
  13. #include "PMEventRec.h"
  14. #include "CIBasic.h"
  15. #include "PMInterfaceIDs.h"
  16. #include "CICommandsAndQueries.h"
  17.  
  18.  
  19. /* ---------------- Plug-in include files ---------------- */
  20. #include "OpenCpy.h"
  21. #ifdef MACINTOSH
  22.     #include "WinTypes.h"
  23.     #include "PStrUtils.h"
  24. #endif // MACINTOSH
  25.  
  26. /* ---------------- Cross-platform include files ---------------- */
  27.  
  28. /* ---------------- Platform specific include files ---------------- */
  29. #ifdef MACINTOSH
  30.     #include <types.h>
  31.     #ifndef powerc
  32.         #include <A4Stuff.h>
  33.         #include <SetUpA4.h>
  34.     #endif
  35. #else
  36.     #include <windows.h>
  37. #endif
  38.  
  39. /* ---------------- Type definitions ---------------- */
  40.  
  41. /* ---------------- Definitions ---------------- */
  42. #define        CB_PATH_BUFF        1000
  43. #define        CB_NAME_BUFF        300
  44.  
  45. /* ---------------- PageMaker (New)SDK include files ---------------- */
  46.  
  47. /* ---------------- Globals ---------------- */
  48. extern    sPMParamBlockPtr thePB;
  49. extern CIInterfaceManager    *gpIntfMgr;
  50.  
  51.  
  52. /* ---------------- Function declarations ---------------- */
  53. #ifdef WINDOWS
  54. extern BOOL    FGetOpenFileName(char *szPName, short cbPSz, char *szSName, short cbSSz ); 
  55. #endif // WINDOWS
  56.  
  57. void OpenPubCopy(void)
  58. {
  59.     //return;
  60.     BOOL    result;
  61. #ifdef WINDOWS
  62.     char    *szPathName = NULL;
  63.     char    *szShortName = NULL;
  64. #endif //WINDOWS
  65. #ifdef MACINTOSH
  66.     Point        point;
  67.     short         numTypes = 1;
  68.     SFTypeList    typeList;
  69.     SFReply        reply;
  70. #endif // MACINTOSH
  71.     struct OpenPub {
  72.         char    szPathDestination[91];
  73.         short    how;
  74.     } OpenRec;
  75.     char myBuffer[300];
  76.     char *myBufPtr=myBuffer;
  77.     unsigned long sizeBuf = 0;
  78.     CIBasic *pBasic = (CIBasic *)NULL;
  79.     unsigned long oldProperty, openProperty;
  80.  
  81. #ifdef WINDOWS
  82.      szPathName = (char *)GlobalAlloc( GPTR, CB_PATH_BUFF );
  83.     szShortName = (char *)GlobalAlloc( GPTR, CB_NAME_BUFF );
  84.  
  85.      if ( !szPathName || !szShortName )
  86.         goto cleanup;
  87.  
  88.     result = FGetOpenFileName(szPathName, CB_PATH_BUFF, szShortName, CB_NAME_BUFF);
  89.  
  90.     memset(OpenRec.szPathDestination, 0, 91);
  91.  
  92.     strncpy( OpenRec.szPathDestination, szPathName, 91 );
  93. #endif // WINDOWS
  94.  
  95. #ifdef MACINTOSH
  96.     point.h = 100;
  97.     point.v = 100;
  98.     typeList[0] = 'AB65';
  99.  
  100.     SFGetFile(point, "\pLocate PageMaker file:", nil, numTypes, typeList,
  101.                 nil, &reply);
  102.  
  103.     if (reply.good == false)
  104.         return;
  105.         
  106.     memset(OpenRec.szPathDestination, 0, 91);
  107.  
  108.     p_to_c( OpenRec.szPathDestination, reply.fName);
  109.  
  110. #endif //MACINTOSH
  111. /*
  112.     struct OpenPub {
  113.         char    szPathDestination[91];
  114.         short    how;
  115.     } OpenRec;
  116. */
  117.     OpenRec.how = 1;
  118.  
  119.     gpIntfMgr->AcquirePMInterface((unsigned long)PMIID_BASIC, (void **)&pBasic);
  120.     oldProperty = pBasic->GetPlugInLibProperty();
  121.     openProperty = ( oldProperty | kDisablePMEvent | kDisablePMSysEvent | kDisableNonCQEvent );
  122.     gpIntfMgr->ReleasePMInterface((void *)pBasic);
  123.     
  124.     sizeBuf += LPPutString(myBufPtr, OpenRec.szPathDestination);
  125.     myBufPtr += sizeBuf;
  126.     sizeBuf += LPPutShort(myBufPtr, 1);
  127.     
  128. //    result = PBBinCommand(thePB, pm_open, kXRSPointer, &myBuffer, sizeBuf);
  129.     result = PBBinCommand(thePB, pm_clear, kXRSNull, NULL, 0);
  130.  
  131.     gpIntfMgr->AcquirePMInterface((unsigned long)PMIID_BASIC, (void **)&pBasic);
  132.     pBasic->SetPlugInLibProperty(oldProperty);
  133.     gpIntfMgr->ReleasePMInterface((void *)pBasic);
  134.     
  135. cleanup:
  136. #ifdef WINDOWS
  137.     if ( szPathName )
  138.         GlobalFree( szPathName );
  139.     if ( szShortName )
  140.         GlobalFree( szShortName );
  141. #endif //WINDOWS
  142. #ifdef MACINTOSH
  143.  
  144. #endif // MACINTOSH
  145.     return;
  146. }
  147.